package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.result.ResultBuilder;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.WorkReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/v1/workReport")
public class WorkReportController extends BaseController {

    @Autowired
    private WorkReportService workReportService;

    /**
     * 工作报告查询（列表）
     */
    @PostMapping("/selWorkReport")
    public ListResult<Object> selWorkReport(@RequestBody PageData pageData) {
        return ResultBuilder.buildListSuccess(workReportService.selWorkReport(pageData));
    }

    /**
     * 导出
     */
    @PostMapping("/queryAllExportData")
    public JsonObj queryAllExportData(@RequestBody PageData pageData) {
        List<LinkedHashMap<String,Object>> list  = workReportService.queryAllExportData(pageData);
        Map<String,Object> map = new HashMap<>();
        map.put("data",list);
        return JsonObj.success(map);
    }

    /**
     * 大屏数据
     * 2024-4-1：改成按“年份”搜索
     * */
    @GetMapping("/getScreenData")
    public JsonObj getScreenData(@RequestParam(required = false) String year){
        return JsonObj.success(workReportService.getScreenData(year));
    }

    /**
     * 大屏数据：获取医院数据
     * 参数：年份 （year）\ 机构id（orgId）
     */
    @PostMapping("/getHospitalDataInit")
    public JsonObj getHospitalDataInit(@RequestBody PageData pageData){
        return JsonObj.success(workReportService.getHospitalDataInit(pageData));
    }

    /**
     * 获取医院对应的城市
     */
    @GetMapping("/getCityByHospital")
    public JsonObj getCityByHospital(){
        return JsonObj.success(workReportService.getCityByHospital());
    }
}
